import { createRouter, createWebHistory, RouteRecordRaw } from 'vue-router'

import LayOut from '@/layout/index.vue'

const routes: Array<RouteRecordRaw> = [
    {
        path: '/',
        component: LayOut,
        redirect: '/home',
        children: [
            {
                path: '/home',
                name: 'home',
                component: () => import('@/pages/home/index.vue'),
                hidden: false,
                meta: {
                    index: '1',
                    title: '首页',
                    icon: '',
                },
            },
            {
                path: '/program',
                name: 'program',
                component: () => import('@/pages/program/index.vue'),
                hidden: false,
                meta: {
                    index: '2',
                    title: '编程知识',
                    icon: '',
                },
                children: [
                    {
                        path: '/program/front',
                        name: 'program-front',
                        component: () => import('@/pages/program/front/index.vue'),
                        meta: {
                            index: '2-1',
                            title: '前端',
                            icon: '',
                        },
                    },
                    {
                        path: '/program/behind',
                        name: 'program-behind',
                        component: () => import('@/pages/program/behind/index.vue'),
                        meta: {
                            index: '2-2',
                            title: '后端',
                            icon: '',
                        },
                    },
                ],
            },
            {
                path: '/about',
                name: 'about',
                component: () => import('@/pages/about/index.vue'),
                meta: {
                    index: '3',
                    title: '关于',
                    icon: '',
                },
            },
        ],
    },
]

const router = createRouter({
    history: createWebHistory(),
    routes,
})

export default router
